package dm.ast;

import test.envset.GlobalState;

/**
 * @author weihuixin
 * @date 2024/4/15
 * @Description
 */
public class DmRownumExpression extends DmBoolExpression{

    @Override
    public void setWidt() {
        if(expRight != null){
          expRight.setWidt();
          wid_t = 2 + expRight.getWidt();
        }
    }

    @Override
    public void setDept() {
        if(expRight != null){
            expRight.setDept();
            wid_t = expRight.getDept();
        }
    }

    @Override
    public String toSql() {
        StringBuilder sql = new StringBuilder();
        sql.append(" ROWNUM ");
        sql.append(op.toSql());
        sql.append(expRight.toSqlClose());
        return sql.toString();
    }

    @Override
    public void fill(GlobalState globalState) {
        if(!isCompleted){
            expRight.fill(globalState);
            isCompleted = true;
        }
    }
}
